package options

import (
	"time"

	"gitee.com/sdxstar/air/codec"
	"gitee.com/sdxstar/air/logger"
	"gitee.com/sdxstar/air/protocol"
)

type AddressFetcher func() (string, error)

type ClientOptions struct {
	// common
	WorkId                 uint16
	AddressFetcher         AddressFetcher
	PacketSendChanLimit    uint32
	PacketReceiveChanLimit uint32
	MessageTimeout         time.Duration
	Codec                  codec.Codec
	Protocol               protocol.Protocol
	Logger                 logger.Logger

	// only for client
	HeartbeatInterval time.Duration
	ReconnectInterval time.Duration
	ReconnectLimit    uint32
	Reconnect         bool
}

func DefaultClientOptions() *ClientOptions {
	return &ClientOptions{
		// common
		WorkId: 1,
		AddressFetcher: func() (string, error) {
			return ":1200", nil
		},
		MessageTimeout:         5 * time.Second,
		PacketSendChanLimit:    1,
		PacketReceiveChanLimit: 1,
		Codec:                  codec.NewDefaultCodec(),
		Protocol:               protocol.NewDefaultProtocol(),

		// only for client
		HeartbeatInterval: 30 * time.Second,
		ReconnectInterval: 10 * time.Second,
		ReconnectLimit:    0,
		Reconnect:         false,
	}
}
